{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2022_09_05'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "day = datetime.datetime.strftime(datetime.datetime.now(), \"%Y_%m_%d\")\n",
    "day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 66240\r\n",
      "-rw-r--r--@ 1 ivan  staff   565464  7 30 18:56 eqList2022_07_30.xlsx\r\n",
      "-rw-r--r--@ 1 ivan  staff   566439  8  9 01:05 eqList2022_08_09.xlsx\r\n",
      "-rw-r--r--@ 1 ivan  staff  3567272  8 11 11:27 eqList2022_08_11.xls\r\n",
      "-rw-r--r--@ 1 ivan  staff   566428  8 11 00:45 eqList2022_08_11.xlsx\r\n",
      "-rw-r--r--@ 1 ivan  staff  3568288  8 12 16:56 eqList2022_08_12.xls\r\n",
      "-rw-r--r--@ 1 ivan  staff  3569648  8 13 15:09 eqList2022_08_13.xls\r\n",
      "-rw-r--r--@ 1 ivan  staff  3573668  8 15 16:06 eqList2022_08_15.xls\r\n",
      "-rw-r--r--@ 1 ivan  staff  3575011  8 16 18:58 eqList2022_08_16.xls\r\n",
      "-rw-r--r--@ 1 ivan  staff  3576341  8 19 17:36 eqList2022_08_19.xls\r\n",
      "-rw-r--r--@ 1 ivan  staff  3581086  8 26 10:12 eqList2022_08_26.xls\r\n",
      "-rw-r--r--@ 1 ivan  staff  3585174  9  2 01:05 eqList2022_09_02.xls\r\n",
      "-rw-r--r--@ 1 ivan  staff  3590551  9  5 16:37 eqList2022_09_05.xls\r\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'eqList/eqList2022_09_05.xls'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "! rm -rf \"eqList/eqList\"$day\".xls\"\n",
    "! cp \"/Users/ivan/Downloads/eqList\"$day\".xls\" \"eqList/eqList\"$day\".xls\"\n",
    "! ls -l \"eqList/\"\n",
    "\n",
    "aeta = f\"eqList/eqList{day}.xls\"\n",
    "aeta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "N = 1\n",
    "T = 10\n",
    "# 经度\n",
    "lonL, lonH = 98, 107\n",
    "# 纬度\n",
    "latL, latH = 22, 34 \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "发震时刻       object\n",
      "震级(M)     float64\n",
      "纬度(°)     float64\n",
      "经度(°)     float64\n",
      "深度(千米)    float64\n",
      "参考位置       object\n",
      "dtype: object\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>发震时刻</th>\n",
       "      <th>震级(M)</th>\n",
       "      <th>纬度(°)</th>\n",
       "      <th>经度(°)</th>\n",
       "      <th>深度(千米)</th>\n",
       "      <th>参考位置</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2022-09-05 13:38:05</td>\n",
       "      <td>3.2</td>\n",
       "      <td>31.91</td>\n",
       "      <td>92.87</td>\n",
       "      <td>10.0</td>\n",
       "      <td>西藏那曲市比如县</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2022-09-05 13:28:46</td>\n",
       "      <td>3.2</td>\n",
       "      <td>29.58</td>\n",
       "      <td>102.06</td>\n",
       "      <td>12.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2022-09-05 13:28:23</td>\n",
       "      <td>2.9</td>\n",
       "      <td>29.49</td>\n",
       "      <td>102.17</td>\n",
       "      <td>10.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2022-09-05 13:15:31</td>\n",
       "      <td>2.8</td>\n",
       "      <td>29.51</td>\n",
       "      <td>102.11</td>\n",
       "      <td>8.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2022-09-05 13:10:24</td>\n",
       "      <td>2.9</td>\n",
       "      <td>29.46</td>\n",
       "      <td>102.14</td>\n",
       "      <td>10.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2022-09-05 13:03:14</td>\n",
       "      <td>3.1</td>\n",
       "      <td>29.61</td>\n",
       "      <td>102.04</td>\n",
       "      <td>9.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2022-09-05 12:56:34</td>\n",
       "      <td>4.2</td>\n",
       "      <td>29.40</td>\n",
       "      <td>102.17</td>\n",
       "      <td>15.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2022-09-05 12:52:18</td>\n",
       "      <td>6.8</td>\n",
       "      <td>29.59</td>\n",
       "      <td>102.08</td>\n",
       "      <td>16.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2022-09-05 08:48:43</td>\n",
       "      <td>4.0</td>\n",
       "      <td>33.77</td>\n",
       "      <td>89.04</td>\n",
       "      <td>10.0</td>\n",
       "      <td>西藏那曲市双湖县</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2022-09-05 05:57:39</td>\n",
       "      <td>5.1</td>\n",
       "      <td>34.60</td>\n",
       "      <td>70.70</td>\n",
       "      <td>20.0</td>\n",
       "      <td>阿富汗</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  发震时刻  震级(M)  纬度(°)   经度(°)  深度(千米)      参考位置\n",
       "0  2022-09-05 13:38:05    3.2  31.91   92.87    10.0  西藏那曲市比如县\n",
       "1  2022-09-05 13:28:46    3.2  29.58  102.06    12.0  四川甘孜州泸定县\n",
       "2  2022-09-05 13:28:23    2.9  29.49  102.17    10.0  四川雅安市石棉县\n",
       "3  2022-09-05 13:15:31    2.8  29.51  102.11     8.0  四川甘孜州泸定县\n",
       "4  2022-09-05 13:10:24    2.9  29.46  102.14    10.0  四川雅安市石棉县\n",
       "5  2022-09-05 13:03:14    3.1  29.61  102.04     9.0  四川甘孜州泸定县\n",
       "6  2022-09-05 12:56:34    4.2  29.40  102.17    15.0  四川雅安市石棉县\n",
       "7  2022-09-05 12:52:18    6.8  29.59  102.08    16.0  四川甘孜州泸定县\n",
       "8  2022-09-05 08:48:43    4.0  33.77   89.04    10.0  西藏那曲市双湖县\n",
       "9  2022-09-05 05:57:39    5.1  34.60   70.70    20.0       阿富汗"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "import xml\n",
    "DOMTree = xml.dom.minidom.parse(aeta).documentElement\n",
    "Row = DOMTree.getElementsByTagName(\"Row\")\n",
    "\n",
    "cols, data = [], []\n",
    "for nRow, iRow in enumerate(Row):\n",
    "    if nRow == 0:\n",
    "        for jRow in iRow.getElementsByTagName(\"Cell\"):\n",
    "            cols.append(jRow.childNodes[0].childNodes[0].data)\n",
    "    else:\n",
    "        idata = []\n",
    "        for jRow in iRow.getElementsByTagName(\"Cell\"):\n",
    "            idata.append(jRow.childNodes[0].childNodes[0].data)\n",
    "        data.append([float(dj) if nj in [1,2,3,4] else str(dj) for nj ,dj in enumerate(idata)])\n",
    "\n",
    "data = pd.DataFrame(data, columns=cols)\n",
    "print(data.dtypes)\n",
    "data.head(T)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def regeo(location):\n",
    "    try:\n",
    "        import json\n",
    "        import requests\n",
    "\n",
    "        host = 'https://regeo.market.alicloudapi.com'\n",
    "        path = '/v3/geocode/regeo'\n",
    "        appcode = '830fa522a512421eaa202bb80afe8921'\n",
    "        querys = f'location={location}' # 经度在前，纬度在后\n",
    "        with requests.get(\n",
    "            f\"{host}{path}?{querys}\", \n",
    "            headers={'Authorization': f'APPCODE {appcode}'}\n",
    "        ) as r:\n",
    "            j = json.loads(r.content.decode())[\"regeocode\"][\"formatted_address\"]\n",
    "            return j\n",
    "    except:\n",
    "        return \"NaN\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 10/10 [00:02<00:00,  3.64it/s]\n"
     ]
    }
   ],
   "source": [
    "\n",
    "Kdata = []\n",
    "for STATION in tqdm(data.head(T)[\"参考位置\"]):\n",
    "    # idata\n",
    "    idata = data[data[\"参考位置\"] == STATION][[\"参考位置\", \"发震时刻\"]]\n",
    "    idata.rename({\n",
    "        \"参考位置\": \"初次参考位置\", \n",
    "        \"发震时刻\": \"初次发震时刻\",\n",
    "    }, axis=1, inplace=True)\n",
    "    idata[\"K\"] = 1\n",
    "    # print(idata.shape)\n",
    "\n",
    "    # jdata\n",
    "    jdata = data[\n",
    "        (data[\"参考位置\"] != STATION) & \n",
    "        (data[\"经度(°)\"] >= lonL) & (data[\"经度(°)\"] <= lonH) &\n",
    "        (data[\"纬度(°)\"] >= latL) & (data[\"纬度(°)\"] <= latH) &\n",
    "        # (data[\"震级(M)\"] >= 3.5) &\n",
    "        True\n",
    "    ][[\"参考位置\", \"震级(M)\", \"纬度(°)\", \"经度(°)\", \"发震时刻\"]]\n",
    "    jdata[\"K\"] = 1\n",
    "    # print(jdata.shape)\n",
    "\n",
    "    # k0data\n",
    "    k0data = pd.merge(\n",
    "        idata,\n",
    "        jdata,\n",
    "        on=\"K\"\n",
    "    )\n",
    "    # print(k0data.shape)\n",
    "\n",
    "    # k1data\n",
    "    # 筛选近N天内\n",
    "    k0data[\"gap-发震时刻\"] = (\n",
    "        pd.to_datetime(k0data[\"发震时刻\"]) - \n",
    "        pd.to_datetime(k0data[\"初次发震时刻\"])\n",
    "    ).dt.days\n",
    "\n",
    "    k1data = (k0data[\"gap-发震时刻\"] >= 1) & (k0data[\"gap-发震时刻\"] <= N)\n",
    "    # print(pd.value_counts(k1data))\n",
    "\n",
    "    k1data = k0data[k1data]\n",
    "    # print(k1data.shape)\n",
    "\n",
    "    # k2data\n",
    "    k2data = k1data.groupby(\n",
    "        [\"初次参考位置\", \"初次发震时刻\", \"K\"], \n",
    "        as_index=False\n",
    "    ).agg({\n",
    "        \"震级(M)\": \"mean\", # 特殊/余震\n",
    "        \"纬度(°)\": \"mean\",\n",
    "        \"经度(°)\": \"mean\",\n",
    "    }).groupby(\n",
    "        [\"K\"], \n",
    "        as_index=False\n",
    "    ).agg(\n",
    "        {\n",
    "        \"K\": \"sum\",\n",
    "        \"震级(M)\": \"mean\", \n",
    "        \"纬度(°)\": \"mean\",\n",
    "        \"经度(°)\": \"mean\",\n",
    "    })\n",
    "\n",
    "    k2data[\"参考位置\"] = STATION\n",
    "    k2data[\"K%\"] = k2data[\"K\"]/idata.shape[0]\n",
    "    k2data[\"震级C\"] = k2data[\"震级(M)\"].apply(lambda x: \"\" if x >= 3.5 else \"❌\")\n",
    "    k2data[\"经度C\"] = k2data[\"经度(°)\"].apply(lambda x: \"\" if x >= lonL and x <= lonH else \"❌\")\n",
    "    k2data[\"纬度C\"] = k2data[\"纬度(°)\"].apply(lambda x: \"\" if x >= latL and x <= latH else \"❌\")\n",
    "    k2data[\"经纬度解析\"] = [regeo(f\"{_1},{_2}\") for _1, _2 in zip(k2data[\"经度(°)\"], k2data[\"纬度(°)\"])]\n",
    "    k2data[\"经度(°)\"] = k2data[\"经度(°)\"].apply(lambda x: f\"{x:.6f}\")\n",
    "    k2data[\"纬度(°)\"] = k2data[\"纬度(°)\"].apply(lambda x: f\"{x:.6f}\")\n",
    "\n",
    "    k2data = k2data[\n",
    "        ['参考位置', '震级(M)', '震级C', '纬度(°)', '纬度C', '经度(°)', '经度C', 'K', 'K%','经纬度解析']\n",
    "    ]\n",
    "    # print(k2data)\n",
    "    Kdata.append(k2data)\n",
    "\n",
    "    # \n",
    "    del idata, jdata, k0data, k1data, k2data\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>#发震时刻#</th>\n",
       "      <th>#震级(M)#</th>\n",
       "      <th>#纬度(°)#</th>\n",
       "      <th>#经度(°)#</th>\n",
       "      <th>#深度(千米)#</th>\n",
       "      <th>参考位置</th>\n",
       "      <th>震级(M)</th>\n",
       "      <th>震级C</th>\n",
       "      <th>纬度(°)</th>\n",
       "      <th>纬度C</th>\n",
       "      <th>经度(°)</th>\n",
       "      <th>经度C</th>\n",
       "      <th>K</th>\n",
       "      <th>K%</th>\n",
       "      <th>经纬度解析</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2022-09-05 13:38:05</td>\n",
       "      <td>3.2</td>\n",
       "      <td>31.91</td>\n",
       "      <td>92.87</td>\n",
       "      <td>10.0</td>\n",
       "      <td>西藏那曲市比如县</td>\n",
       "      <td>3.840000</td>\n",
       "      <td></td>\n",
       "      <td>27.817500</td>\n",
       "      <td></td>\n",
       "      <td>102.898500</td>\n",
       "      <td></td>\n",
       "      <td>4</td>\n",
       "      <td>0.235294</td>\n",
       "      <td>四川省凉山彝族自治州布拖县俄里坪镇李子</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2022-09-05 13:28:46</td>\n",
       "      <td>3.2</td>\n",
       "      <td>29.58</td>\n",
       "      <td>102.06</td>\n",
       "      <td>12.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2022-09-05 13:28:46</td>\n",
       "      <td>3.2</td>\n",
       "      <td>29.58</td>\n",
       "      <td>102.06</td>\n",
       "      <td>12.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2022-09-05 13:28:46</td>\n",
       "      <td>3.2</td>\n",
       "      <td>29.58</td>\n",
       "      <td>102.06</td>\n",
       "      <td>12.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2022-09-05 13:28:46</td>\n",
       "      <td>3.2</td>\n",
       "      <td>29.58</td>\n",
       "      <td>102.06</td>\n",
       "      <td>12.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2022-09-05 13:28:23</td>\n",
       "      <td>2.9</td>\n",
       "      <td>29.49</td>\n",
       "      <td>102.17</td>\n",
       "      <td>10.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "      <td>2.975000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.854000</td>\n",
       "      <td></td>\n",
       "      <td>104.346000</td>\n",
       "      <td></td>\n",
       "      <td>5</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>四川省宜宾市屏山县屏山镇天之华大道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2022-09-05 13:28:23</td>\n",
       "      <td>2.9</td>\n",
       "      <td>29.49</td>\n",
       "      <td>102.17</td>\n",
       "      <td>10.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "      <td>2.975000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.854000</td>\n",
       "      <td></td>\n",
       "      <td>104.346000</td>\n",
       "      <td></td>\n",
       "      <td>5</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>四川省宜宾市屏山县屏山镇天之华大道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2022-09-05 13:28:23</td>\n",
       "      <td>2.9</td>\n",
       "      <td>29.49</td>\n",
       "      <td>102.17</td>\n",
       "      <td>10.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "      <td>2.975000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.854000</td>\n",
       "      <td></td>\n",
       "      <td>104.346000</td>\n",
       "      <td></td>\n",
       "      <td>5</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>四川省宜宾市屏山县屏山镇天之华大道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2022-09-05 13:15:31</td>\n",
       "      <td>2.8</td>\n",
       "      <td>29.51</td>\n",
       "      <td>102.11</td>\n",
       "      <td>8.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2022-09-05 13:15:31</td>\n",
       "      <td>2.8</td>\n",
       "      <td>29.51</td>\n",
       "      <td>102.11</td>\n",
       "      <td>8.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2022-09-05 13:15:31</td>\n",
       "      <td>2.8</td>\n",
       "      <td>29.51</td>\n",
       "      <td>102.11</td>\n",
       "      <td>8.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2022-09-05 13:15:31</td>\n",
       "      <td>2.8</td>\n",
       "      <td>29.51</td>\n",
       "      <td>102.11</td>\n",
       "      <td>8.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2022-09-05 13:10:24</td>\n",
       "      <td>2.9</td>\n",
       "      <td>29.46</td>\n",
       "      <td>102.14</td>\n",
       "      <td>10.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "      <td>2.975000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.854000</td>\n",
       "      <td></td>\n",
       "      <td>104.346000</td>\n",
       "      <td></td>\n",
       "      <td>5</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>四川省宜宾市屏山县屏山镇天之华大道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2022-09-05 13:10:24</td>\n",
       "      <td>2.9</td>\n",
       "      <td>29.46</td>\n",
       "      <td>102.14</td>\n",
       "      <td>10.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "      <td>2.975000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.854000</td>\n",
       "      <td></td>\n",
       "      <td>104.346000</td>\n",
       "      <td></td>\n",
       "      <td>5</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>四川省宜宾市屏山县屏山镇天之华大道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2022-09-05 13:10:24</td>\n",
       "      <td>2.9</td>\n",
       "      <td>29.46</td>\n",
       "      <td>102.14</td>\n",
       "      <td>10.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "      <td>2.975000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.854000</td>\n",
       "      <td></td>\n",
       "      <td>104.346000</td>\n",
       "      <td></td>\n",
       "      <td>5</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>四川省宜宾市屏山县屏山镇天之华大道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2022-09-05 13:03:14</td>\n",
       "      <td>3.1</td>\n",
       "      <td>29.61</td>\n",
       "      <td>102.04</td>\n",
       "      <td>9.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2022-09-05 13:03:14</td>\n",
       "      <td>3.1</td>\n",
       "      <td>29.61</td>\n",
       "      <td>102.04</td>\n",
       "      <td>9.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2022-09-05 13:03:14</td>\n",
       "      <td>3.1</td>\n",
       "      <td>29.61</td>\n",
       "      <td>102.04</td>\n",
       "      <td>9.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2022-09-05 13:03:14</td>\n",
       "      <td>3.1</td>\n",
       "      <td>29.61</td>\n",
       "      <td>102.04</td>\n",
       "      <td>9.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2022-09-05 12:56:34</td>\n",
       "      <td>4.2</td>\n",
       "      <td>29.40</td>\n",
       "      <td>102.17</td>\n",
       "      <td>15.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "      <td>2.975000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.854000</td>\n",
       "      <td></td>\n",
       "      <td>104.346000</td>\n",
       "      <td></td>\n",
       "      <td>5</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>四川省宜宾市屏山县屏山镇天之华大道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2022-09-05 12:56:34</td>\n",
       "      <td>4.2</td>\n",
       "      <td>29.40</td>\n",
       "      <td>102.17</td>\n",
       "      <td>15.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "      <td>2.975000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.854000</td>\n",
       "      <td></td>\n",
       "      <td>104.346000</td>\n",
       "      <td></td>\n",
       "      <td>5</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>四川省宜宾市屏山县屏山镇天之华大道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2022-09-05 12:56:34</td>\n",
       "      <td>4.2</td>\n",
       "      <td>29.40</td>\n",
       "      <td>102.17</td>\n",
       "      <td>15.0</td>\n",
       "      <td>四川雅安市石棉县</td>\n",
       "      <td>2.975000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.854000</td>\n",
       "      <td></td>\n",
       "      <td>104.346000</td>\n",
       "      <td></td>\n",
       "      <td>5</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>四川省宜宾市屏山县屏山镇天之华大道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2022-09-05 12:52:18</td>\n",
       "      <td>6.8</td>\n",
       "      <td>29.59</td>\n",
       "      <td>102.08</td>\n",
       "      <td>16.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2022-09-05 12:52:18</td>\n",
       "      <td>6.8</td>\n",
       "      <td>29.59</td>\n",
       "      <td>102.08</td>\n",
       "      <td>16.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2022-09-05 12:52:18</td>\n",
       "      <td>6.8</td>\n",
       "      <td>29.59</td>\n",
       "      <td>102.08</td>\n",
       "      <td>16.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2022-09-05 12:52:18</td>\n",
       "      <td>6.8</td>\n",
       "      <td>29.59</td>\n",
       "      <td>102.08</td>\n",
       "      <td>16.0</td>\n",
       "      <td>四川甘孜州泸定县</td>\n",
       "      <td>3.200000</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.140000</td>\n",
       "      <td></td>\n",
       "      <td>99.562500</td>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>0.153846</td>\n",
       "      <td>云南省迪庆藏族自治州香格里拉市格咱乡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2022-09-05 08:48:43</td>\n",
       "      <td>4.0</td>\n",
       "      <td>33.77</td>\n",
       "      <td>89.04</td>\n",
       "      <td>10.0</td>\n",
       "      <td>西藏那曲市双湖县</td>\n",
       "      <td>3.178571</td>\n",
       "      <td>❌</td>\n",
       "      <td>28.845000</td>\n",
       "      <td></td>\n",
       "      <td>104.223571</td>\n",
       "      <td></td>\n",
       "      <td>7</td>\n",
       "      <td>0.145833</td>\n",
       "      <td>四川省宜宾市叙州区蕨溪镇025乡道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2022-09-05 05:57:39</td>\n",
       "      <td>5.1</td>\n",
       "      <td>34.60</td>\n",
       "      <td>70.70</td>\n",
       "      <td>20.0</td>\n",
       "      <td>阿富汗</td>\n",
       "      <td>3.257143</td>\n",
       "      <td>❌</td>\n",
       "      <td>29.827857</td>\n",
       "      <td></td>\n",
       "      <td>103.436429</td>\n",
       "      <td></td>\n",
       "      <td>7</td>\n",
       "      <td>0.291667</td>\n",
       "      <td>四川省眉山市洪雅县余坪镇宋村</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 #发震时刻#  #震级(M)#  #纬度(°)#  #经度(°)#  #深度(千米)#      参考位置  \\\n",
       "0   2022-09-05 13:38:05      3.2    31.91    92.87      10.0  西藏那曲市比如县   \n",
       "1   2022-09-05 13:28:46      3.2    29.58   102.06      12.0  四川甘孜州泸定县   \n",
       "2   2022-09-05 13:28:46      3.2    29.58   102.06      12.0  四川甘孜州泸定县   \n",
       "3   2022-09-05 13:28:46      3.2    29.58   102.06      12.0  四川甘孜州泸定县   \n",
       "4   2022-09-05 13:28:46      3.2    29.58   102.06      12.0  四川甘孜州泸定县   \n",
       "19  2022-09-05 13:28:23      2.9    29.49   102.17      10.0  四川雅安市石棉县   \n",
       "18  2022-09-05 13:28:23      2.9    29.49   102.17      10.0  四川雅安市石棉县   \n",
       "17  2022-09-05 13:28:23      2.9    29.49   102.17      10.0  四川雅安市石棉县   \n",
       "5   2022-09-05 13:15:31      2.8    29.51   102.11       8.0  四川甘孜州泸定县   \n",
       "6   2022-09-05 13:15:31      2.8    29.51   102.11       8.0  四川甘孜州泸定县   \n",
       "7   2022-09-05 13:15:31      2.8    29.51   102.11       8.0  四川甘孜州泸定县   \n",
       "8   2022-09-05 13:15:31      2.8    29.51   102.11       8.0  四川甘孜州泸定县   \n",
       "20  2022-09-05 13:10:24      2.9    29.46   102.14      10.0  四川雅安市石棉县   \n",
       "21  2022-09-05 13:10:24      2.9    29.46   102.14      10.0  四川雅安市石棉县   \n",
       "22  2022-09-05 13:10:24      2.9    29.46   102.14      10.0  四川雅安市石棉县   \n",
       "12  2022-09-05 13:03:14      3.1    29.61   102.04       9.0  四川甘孜州泸定县   \n",
       "10  2022-09-05 13:03:14      3.1    29.61   102.04       9.0  四川甘孜州泸定县   \n",
       "9   2022-09-05 13:03:14      3.1    29.61   102.04       9.0  四川甘孜州泸定县   \n",
       "11  2022-09-05 13:03:14      3.1    29.61   102.04       9.0  四川甘孜州泸定县   \n",
       "25  2022-09-05 12:56:34      4.2    29.40   102.17      15.0  四川雅安市石棉县   \n",
       "24  2022-09-05 12:56:34      4.2    29.40   102.17      15.0  四川雅安市石棉县   \n",
       "23  2022-09-05 12:56:34      4.2    29.40   102.17      15.0  四川雅安市石棉县   \n",
       "14  2022-09-05 12:52:18      6.8    29.59   102.08      16.0  四川甘孜州泸定县   \n",
       "16  2022-09-05 12:52:18      6.8    29.59   102.08      16.0  四川甘孜州泸定县   \n",
       "15  2022-09-05 12:52:18      6.8    29.59   102.08      16.0  四川甘孜州泸定县   \n",
       "13  2022-09-05 12:52:18      6.8    29.59   102.08      16.0  四川甘孜州泸定县   \n",
       "26  2022-09-05 08:48:43      4.0    33.77    89.04      10.0  西藏那曲市双湖县   \n",
       "27  2022-09-05 05:57:39      5.1    34.60    70.70      20.0       阿富汗   \n",
       "\n",
       "       震级(M) 震级C      纬度(°) 纬度C       经度(°) 经度C  K        K%  \\\n",
       "0   3.840000      27.817500      102.898500      4  0.235294   \n",
       "1   3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "2   3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "3   3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "4   3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "19  2.975000   ❌  28.854000      104.346000      5  0.454545   \n",
       "18  2.975000   ❌  28.854000      104.346000      5  0.454545   \n",
       "17  2.975000   ❌  28.854000      104.346000      5  0.454545   \n",
       "5   3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "6   3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "7   3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "8   3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "20  2.975000   ❌  28.854000      104.346000      5  0.454545   \n",
       "21  2.975000   ❌  28.854000      104.346000      5  0.454545   \n",
       "22  2.975000   ❌  28.854000      104.346000      5  0.454545   \n",
       "12  3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "10  3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "9   3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "11  3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "25  2.975000   ❌  28.854000      104.346000      5  0.454545   \n",
       "24  2.975000   ❌  28.854000      104.346000      5  0.454545   \n",
       "23  2.975000   ❌  28.854000      104.346000      5  0.454545   \n",
       "14  3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "16  3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "15  3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "13  3.200000   ❌  28.140000       99.562500      2  0.153846   \n",
       "26  3.178571   ❌  28.845000      104.223571      7  0.145833   \n",
       "27  3.257143   ❌  29.827857      103.436429      7  0.291667   \n",
       "\n",
       "                  经纬度解析  \n",
       "0   四川省凉山彝族自治州布拖县俄里坪镇李子  \n",
       "1    云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "2    云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "3    云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "4    云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "19    四川省宜宾市屏山县屏山镇天之华大道  \n",
       "18    四川省宜宾市屏山县屏山镇天之华大道  \n",
       "17    四川省宜宾市屏山县屏山镇天之华大道  \n",
       "5    云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "6    云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "7    云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "8    云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "20    四川省宜宾市屏山县屏山镇天之华大道  \n",
       "21    四川省宜宾市屏山县屏山镇天之华大道  \n",
       "22    四川省宜宾市屏山县屏山镇天之华大道  \n",
       "12   云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "10   云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "9    云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "11   云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "25    四川省宜宾市屏山县屏山镇天之华大道  \n",
       "24    四川省宜宾市屏山县屏山镇天之华大道  \n",
       "23    四川省宜宾市屏山县屏山镇天之华大道  \n",
       "14   云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "16   云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "15   云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "13   云南省迪庆藏族自治州香格里拉市格咱乡  \n",
       "26    四川省宜宾市叙州区蕨溪镇025乡道  \n",
       "27       四川省眉山市洪雅县余坪镇宋村  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "endata = pd.merge(\n",
    "    data.head(T).rename(\n",
    "        {icol: f\"#{icol}#\" for icol in data.columns if icol != \"参考位置\"}, \n",
    "        axis=1\n",
    "    ), \n",
    "    pd.concat(Kdata),\n",
    "    on=\"参考位置\"\n",
    ").sort_values(\"#发震时刻#\", ascending=False)\n",
    "\n",
    "endata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      ">>> 2022-09-06 To 2022-09-12 / 2022-09-06\n",
      "\n",
      "# 有震预测 earthquake prediction\n",
      "check_my_prediction(myToken, '2022-09-06', '2022-09-06', 1, latitude=27.817500, longitude=102.898500, magnitude=3.8)\n",
      "\n",
      "\n",
      "# 无震预测 No earthquake prediction\n",
      "check_my_prediction(myToken, '2022-09-06', '2022-09-12', 0)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# \n",
    "day1 = datetime.datetime.strftime(datetime.datetime.now() + datetime.timedelta(days=1), \"%Y-%m-%d\")\n",
    "dayn = datetime.datetime.strftime(datetime.datetime.now() + datetime.timedelta(days=N), \"%Y-%m-%d\")\n",
    "day7 = datetime.datetime.strftime(datetime.datetime.now() + datetime.timedelta(days=7), \"%Y-%m-%d\")\n",
    "print(f\">>> {day1} To {day7} / {dayn}\")\n",
    "\n",
    "message = f\"\"\"\n",
    "# 有震预测 earthquake prediction\n",
    "check_my_prediction(myToken, '{day1}', '{dayn}', 1, latitude=$_1, longitude=$_2, magnitude=$_3)\n",
    "\"\"\"\n",
    "endata = endata[endata[\"震级C\"] != \"❌\"]\n",
    "for _1, _2, _3 in zip(endata[\"纬度(°)\"], endata[\"经度(°)\"], endata[\"震级(M)\"]):\n",
    "    print(message\n",
    "          .replace(\"$_1\",f\"{float(_1):.6f}\")\n",
    "          .replace(\"$_2\",f\"{float(_2):.6f}\")\n",
    "          .replace(\"$_3\",f\"{float(_3):.1f}\")\n",
    "         )\n",
    "\n",
    "message = f\"\"\"\n",
    "# 无震预测 No earthquake prediction\n",
    "check_my_prediction(myToken, '{day1}', '{day7}', 0)\n",
    "\"\"\"\n",
    "print(message)\n",
    "print()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 304\r\n",
      "-rw-r--r--@ 1 ivan  staff  34490  8 16 18:58 Test002-2022_08_16.ipynb\r\n",
      "-rw-r--r--@ 1 ivan  staff  33275  8 19 17:36 Test002-2022_08_19.ipynb\r\n",
      "-rw-r--r--@ 1 ivan  staff  33096  8 26 10:12 Test002-2022_08_26.ipynb\r\n",
      "-rw-r--r--@ 1 ivan  staff  29782  9  2 01:05 Test002-2022_09_02.ipynb\r\n",
      "-rw-r--r--@ 1 ivan  staff   8874  9  5 16:37 Test002-2022_09_05.ipynb\r\n"
     ]
    }
   ],
   "source": [
    "! cp Test002.ipynb \"back/Test002-\"$day\".ipynb\"\n",
    "! ls -l back/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
